using UnityEngine;

namespace GameCore
{
    public class AssetBundleCache
    {
        private AssetBundle bundle;

        private float lastUsed;

        public AssetBundle Bundle { 
            get  {
                lastUsed = Time.unscaledTime;
                return bundle;
            }
            set => bundle = value; }

        public AssetBundleCache()
        {
            lastUsed = Time.unscaledTime;
        }

        public bool IsOutOfDate()
        {
            float gap = Time.unscaledTime - lastUsed;
            if(gap > 10f)
            {
                return true;
            }
            return false;
        }

        public void Unload(bool unloadAllLoadedObjects = false)
        {
            bundle.Unload(unloadAllLoadedObjects);
        }

    }

}